<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
                    <div class="row">
                        <div class="col-sm-12">
                             <div class="box">
                                <div class="box-header with-border">
                                    <div class=" col-sm-6">
                                      
                                        
                                    </div>
                                    <h3 class="box-title pull-right">
                                    <a href="/backend/paypal/account" class="btn btn-sm btn-info btn-flat">返回列表</a>
                                    </h3>
                                </div>
                                <div class="box-body">
                                       <?php if($listsites):?>
                                    <table class="table table-striped table-hover" style="margin-top:20px;">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>站点名称</th>
                                                <th>URL地址</th>
                                                <th>绑定时间</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
<?php foreach ($listsites as $item):?>
<tr shopid="<?php echo $item["siteid"]; ?>">
    <td><?php echo $item["siteid"]; ?></td>
    <td><?php echo $sites[$item["siteid"]]["name"]; ?></td>
    <td><a href="<?php echo $sites[$item["siteid"]]["domian"]; ?>" target="_blank"><?php echo $sites[$item["siteid"]]["domian"]; ?></a></td>
    <td><?php echo $item["addtime"];?></td>
    <td>
    <span class="btn btn-xs btn-flat btn-danger btn-delete" itemid="<?php echo $item["id"];?>"><i class="fa fa-trash-o fa-lg"></i></span>
    </td>
</tr>
<?php endforeach;?>
                                        </tbody>
                                    </table>
<?php endif;?>

                                    <?php 
                                    if(empty($listsites)){
                                        echo "<h2 style='text-align:center;padding:50px 0;'>没有查询到数据</h2>";
                                    }
                                    ?>
                                

                                </div>
                            </div>
                         </div>
                    </div>
        


        <?php echo form_open(current_url(), array('class' => 'form-horizontal','onsubmit'=>'return checkform();', 'id' => 'form-create_notice')); ?>
        <div class="row">
             <div class="col-sm-12">
                <div class="box">
       
                 <div class="box-header with-border">
                 <h3 class="box-title">绑定网站</h3>
                 </div>

                 <div class="box-body">

                    <div class="row">
                        <div class="col-xs-6">
                        <select name="siteid" id="sites" class="form-control" >
                            <?php
                            foreach($sites as $site)
                            {
                            echo '<option value="'.$site["id"].'">'.$site["name"].'</option>';
                            }?>
                        </select>
                        </div>
                    </div>
                  
                  
                    <div class="row" style="margin-top:10px;">
                        <div class="col-xs-3">
                            <input type="hidden" name="action" value="add">
                            <input type="submit" class="btn btn-flat btn-primary btn-sm" value="绑定网站">
                        </div>
                       
                    </div> 

                 </div>
          
              
                </div>
              </div>
            <!-- /.box-body -->
          </div>
        <?php echo form_close();?>
<script>
$(document).ready(function() {
    $('#sites').select2();

    $("span.btn-delete").on("click",function(event){
    var cid=$(this).attr("itemid");
    var row=$(this).parent().parent();
    layer.confirm("确认要删除吗，删除将无法回复？", { title: "确认" }, function (index) {           
            $.ajax({
                type:"post",
                url:"/backend/paypal/account/delsite",
                dataType:"json",
                data:{"cid":cid},
                error:function(){
                },
                success:function(result){
                    if(result["status"]==1)
                    {
                        row.remove();
                    }
                    else
                    {
                        layer.msg(result["msg"]);
                    }
                },
            });
            layer.close(index); 
        });
        
    });


});




</script>
